$(document).ready(function() {
	
	var wizardObj = wizard($("form").attr("id"),"menus",false);
	loadToComboBoxUrl("#pai","menus/combo/nome?class=br.com.educa.modelo.security.Menu","nome");

//-------------------------------------- //////////////////// ------------------------------
	
	//oneToMany Multiselect ----> nomeDisciplinas
	var aoColumnsDisponiveis = [
			{ "sTitle": "Perfis", "mDataProp": "authority", "sClass": "right","sDefaultContent": "" ,"columName": "perfil.authority"}
		];
	var aoColumnsDisponiveisStr = JSON.stringify(aoColumnsDisponiveis, function(key, val) {if (typeof val === 'function') { return val + '';} return val;});
	
	 
		
	var aoColumnsSelecionados = [
			{ "sTitle": "Perfis", "mDataProp": "authority", "sClass": "right","sDefaultContent": "" }
		];
	var aoColumnsSelecionadosStr = JSON.stringify(aoColumnsSelecionados, function(key, val) {if (typeof val === 'function') { return val + '';} return val;});

	multiSelectBServerSideDataGrid("perfisDisponiveisDataGrid", "perfils/bServerSide", "public.perfil", " where true", "br.com.educa.modelo.security.Perfil", aoColumnsDisponiveisStr, "perfisSelecionadasDataGrid",aoColumnsSelecionadosStr, "authority");
	
//-------------------------------------- //////////////////// ------------------------------
    
});

function popular(){
		var registro = new Object();
	    var menu = $("#"+$("form").attr("id")).formParams(false);
	    var perfis = serializarDataGrid("perfisSelecionadasDataGrid");
	     
	     
	     if(menu.pai.id==""){
	    	menu.pai.id=null;
	     }
    
    
		$("select").each(function(){
			try{ 
				eval("menu."+$(this).attr("id")+" = findDataId(menu."+$(this).attr("id")+".id, $(\"#"+$(this).attr("id")+"\").get(0).dataSource);");
			}catch(e){}
		});
	
		registro.menu = menu;
     	registro.perfis = perfis;

     	return registro;
}
